<template>
	<view>
		<headerCome @baocUNsmen="baocUNsmen"></headerCome>
		<view class="" style="padding: 24rpx;">
			<div class="title" v-if="type==1">添加教育经历</div>
			<div class="title" v-if="type==2">添加工作经历</div>
			<view style="border-bottom: 1rpx solid #E1E4E8;">
				<view class="subtitle">
					{{type==1?'学校名称':'工作单位'}}
				</view>
				<input v-model="name" class="conMensge"  placeholder-style="color:#8F9294" placeholder="请输入名称"/>
			</view>
			<view style="border-bottom: 1rpx solid #E1E4E8;" >
				<view class="subtitle">
					学历
				</view>
				<view class="conMensge Mens">
					<picker class="contemNems" style="width: 100%;" @change="funCsiy" :range="xueliScone">
						<view class="flex-line-height flex-height-between tab-anv-list-right">
							<view class="uni-input" v-if="education">{{education}}</view>
							<view v-else>请选择</view>
							<image class="img" :src="imgUrl+'/right.png'" mode=""></image>
						</view>
					</picker>
				</view>
			</view>
			<view style="border-bottom: 1rpx solid #E1E4E8;">
				<view class="subtitle">
					{{type==1?'专业名称':'职位名称'}}
				</view>
				<input  class="conMensge" v-model="zhuanYe" placeholder-style="color:#8F9294" placeholder="请填写"/>
			</view>
			<view style="border-bottom: 1rpx solid #E1E4E8;">
				<view class="subtitle">
					时间
				</view>
				<view  class="conMensge Mens" style="display: flex;align-items: center;justify-content: space-between;">
					<picker class="contemNems" mode="date"  :end="endDate" :value="starttime" fields="month" @change="bindDateChange">
						<view class="uni-input" v-if="starttime">{{starttime}}</view>
						<view v-else>请选择</view>
					</picker> 
					-
					<picker class="contemNems" mode="date" :end="endDate" :value="endtimeMe" fields="month" @change="bindDateChange1">
						<view class="uni-input" v-if="endtimeMe">{{endtimeMe}}</view>
						<view v-else>请选择</view>
					</picker> 
				</view>
			</view>
			
			<view>
				<view class="subtitle" v-if="type==1">
					在校经历
				</view>
				<view class="subtitle" v-if="type==2">
					工作内容
				</view>
			<textarea  style="border: 1rpx solid #E1E4E8; margin-top:20rpx ; width: 100%; padding: 10rpx;" class="textarea" v-model="miaoshu" placeholder-style="color:#8F9294" placeholder="请描述您的经历内容，最少输入10个字"/>
			</view>
		</view>
	</view>
</template>

<script>
	import headerCome from "@/components/header-top.vue"
	import {
		Request
	} from '@/utils/request.js'
	export default{
		components:{
			headerCome
		},
		data(){
			return {
				imgUrl:this.imgUrl,
				textareaMeValue:"",
				name:"",
				zhuanYe:"",
				endDate:'',
				endtimeMe:"",
				miaoshu:"",
				id:"",
				education:'',
				userinfo:{},
				starttime:'',
				date:'',
				type:1,
				xueliScone:['小学','初中','高中（职高，高技、中专）','大专','本科','硕士研究生','博士研究生'],
			}
		},
		onLoad(e) {
			this.type=e.type||1
			this.id=e.webConmen
			this.userinfo=JSON.parse(uni.getStorageSync('userinfo'));
			if(e.webConmen){
				this.showcertificateInformation();
			}
			
		},
		methods:{
			showcertificateInformation(){
				Request('user/curriculum_vitae/showworkExp',{
					id:this.id,
					user_id:this.userinfo.uid,
				},"POST").then((res)=>{
					this.name=res.title
					this.zhuanYe=res.com_name;
					this.education=res.education;
					this.starttime=res.starttime;
					this.miaoshu=res.content,
					this.endtimeMe=res.endtime;
					
					// https://app.zizijy.com/api/user/curriculum_vitae/upcertificateInformation
				})
			},
			// https://app.zizijy.com/api/user/curriculum_vitae/showcertificateInformation
			bindDateChange(e){
				this.starttime=e.detail.value;
			},
			bindDateChange1(e){
				this.endtimeMe=e.detail.value;
			},
			funCsiy(e){
				this.education=this.xueliScone[e.detail.value];
			},
			
			baocUNsmen(){
				if(this.id){
					Request('user/curriculum_vitae/upworkExp',{
						id:this.id,
						starttime:this.starttime,
						endtime:this.endtimeMe,
						title:this.name,
						com_name:this.zhuanYe,
						education:this.education,
						content:this.miaoshu,
						type:this.type,
						user_id:this.userinfo.uid,
					},"POST").then(()=>{
						uni.redirectTo({
							url:`/resume/onLine/index?type=1`
						})
					})
					return false;
				}
				Request('user/curriculum_vitae/workExp',{
					starttime:this.starttime,
					endtime:this.endtimeMe,
					title:this.name,
					com_name:this.zhuanYe,
					content:this.miaoshu,
					education:this.education,
					type:this.type,
					user_id:this.userinfo.uid,
				},"POST").then(()=>{
					uni.redirectTo({
						url:`/resume/onLine/index?type=1`
					})
				})
			}
		}
	}
</script>

<style>
	.title{
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 40rpx;
		color: #0D0E0F;
		text-align: left;
		font-style: normal;
		padding-bottom: 40rpx;
		text-transform: none;
	}
	.contemNems{
		width: 40%;
	}
	.contemNems .img{
		width: 24rpx;
		height: 24rpx;
	}
	.conMensge.Mens {
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 32rpx;
		color: #8F9294;
		text-align: left;
		font-style: normal;
		text-transform: none;
	}
	.conMensge.Mens .uni-input{
		color: #0D0E0F;
	}
	.conMensge{
		font-family: PingFang SC, PingFang SC;
		padding: 24rpx 0;
	}
	.subtitle{
		font-family: PingFang SC, PingFang SC;
		margin-top: 24rpx;
		font-size: 28rpx;
	}
</style>